$(document).ready(function(){
  $('#ddldate, #ddlmonth, #ddlyear').live('change', function() {		
			var date = $("#ddldate").val();
			var month = $("#ddlmonth").val();
			var year = $("#ddlyear").val();
			if(date != "" && month != "" && year != "")
			{
				// var testSiteID = 0;
            $.ajax({
                type: 'POST',
                url: '../trainees/check_test_time_ajax',
                data: "date=" + date + "&month=" + month + "&year=" + year,// + "&testsite=" + testSiteID,
				// dataType:"json",
				success: 	function(msg) 
							{
								$('#errormsg').hide();
								$("#errormsg").html("<span style='font-size:11px; font-family: Tahoma; color:#FF0000'>" + msg + "</span>").show();
								// if(msg == '')
								// {
									// $('#next').attr('href','../trainees/savestep2');
								// }
								// else
								// {
									// $('#next').attr('href','#');
								// }
							}

				// , context:this
            }); 
            // return false;
			}
			
        });
		
	$('#ddldate1, #ddlmonth1, #ddlyear1').live('change', function() {		
		
			var date = $("#ddldate1").val();
			var month = $("#ddlmonth1").val();
			var year = $("#ddlyear1").val();
			if(date != "" && month != "" && year != "")
			{
			var testSiteID = 0;
            $.ajax({
                type: 'POST',
                url: '../trainees/checkVoucherExp',
                data: "date=" + date + "&month=" + month + "&year=" + year,
				// dataType:"json",
				success: 	function(msg) 
							{
								$('#errormsg1').hide();
								$("#errormsg1").html("<span style='font-size:11px; font-family: Tahoma; color:#FF0000'>" + msg + "</span>").show();
							}

				// , context:this
            }); 
            return false;
			}
			
        });
	$('#ddllocation, #ddldate, #ddlmonth, #ddlyear').live('change', function() {
			var location = $("#ddllocation").val();
			var date = $("#ddldate").val();
			var month = $("#ddlmonth").val();
			var year = $("#ddlyear").val();
			if(date != "" && month != "" && year != "")
			{
				$.ajax({
					type: 'POST',
					url: '../trainees/get_timeslot_ajax',
					data: "loc=" + location + "&date=" + date + "&month=" + month + "&year=" + year,
					// dataType:"json",
					success: populateTimeslotList, context:this
				});
			}
	});
});
function populateTimeslotList(response, status) {
	$('#ddltimeslot').html('');
	$('#ddltimeslot').html(response); 
	$('#ddltimeslot').show();	
}